﻿; (function ($) {
    var masterpage = window.masterpage = {
        isHomePage: false,
        noMenu: true,

        contentBodyWidth: 0,
        contentBodyHeight: 0,

        initElements: function() {
        },
        initContentSize: function () {
            var clientWidth = ui.core.root.clientWidth;
            var clientHeight = ui.core.root.clientHeight;
            var tempHead = 0;
            var layoutElem = null;
            for (var i = 0; i < arguments.length; i++) {
                layoutElem = $("#" + arguments[i]);
                if (layoutElem.length > 0) {
                    clientHeight -= layoutElem.height();
                }
            }
            var bodyHeight = clientHeight + "px";
            $("#body").css("height", bodyHeight);
            this.contentBodyHeight = clientHeight;
            this.contentBodyWidth = clientWidth;
        },

        callInitFunc: function (initObj) {
            var func = null;
            if (ui.core.isPlainObject(initObj)) {
                for (var key in initObj) {
                    func = initObj[key];
                    if ($.isFunction(func)) {
                        func();
                    }
                }
            }
        },

        ready: function (func) {
            if ($.isFunction(func)) {
                ui.docReady(func, ui.eventPriority.pageReady);
            }
        },
        resize: function (func) {
            if ($.isFunction(func)) {
                ui.resize(func, ui.eventPriority.elementResize);
            }
        },
        isExcelFile: function (fileName) {
            if (!fileName) {
                return;
            }
            var pointPosition = fileName.lastIndexOf(".");
            var extendName = fileName.substring(pointPosition);
            if (extendName !== ".xls" && extendName !== ".xlsx") {
                ui.msgshow("上传文件格式错误，请选择Excel文件！");
                return false;
            }
            return true;
        },
        isCsvFile: function (fileName) {
            if (!fileName) {
                return;
            }
            var pointPosition = fileName.lastIndexOf(".");
            var extendName = fileName.substring(pointPosition);
            if (extendName !== ".csv") {
                ui.msgshow("上传文件格式错误，请选择csv文件！");
                return false;
            }
            return true;
        },
        //为运单 订单 枚举状态信息转换，数字转换成文字信息
        enums: function (content, columObj) {
            var span = $("<span  style='width:64px;' />");
            if (content === 0) {
                span.text("电商上传");
                span.css("background-color", "#00A500");
            } else if (content === 1) {
                span.text("电商提交");
                span.css("background-color", "#E46522");
            } else if (content === 2) {
                span.text("提报海关");
                span.css("background-color", "#0199FE");
            } else if (content === 3) {
                span.text("海关审结");
                span.css("background-color", "#09A4A8");
            } else if (content === 9) {
                span.text("正在提报");
                span.css("background-color", "#FF00A8");
            } else if (content === 4) {
                span.text("作废");
            } else if (content === 5) {
                span.text("实货放行");
                span.css("background-color", "#09A4A8");
            } else if (content === 6) {
                span.text("汇总报关");
                span.css("background-color", "#9aca40");
            }else {
                span.text("未知");
                span.css("background-color", "#8F8F8F");
            }
            span.addClass("state-text");
            return span;
        }
    };
})(jQuery);